package com.chinatelecom.telecollege.sellerrewarding.controller;

import com.chinatelecom.telecollege.sellerrewarding.Entity.area;
import com.chinatelecom.telecollege.sellerrewarding.service.areaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lenovo on 2017/6/21.
 */
@RestController
public class areaController {
    @Autowired
    private areaService areaService;

    @RequestMapping(value = "/area")
    public area queryarea(@RequestParam int id) {
        return areaService.find(id);
    }

    @RequestMapping(value = "/areaadd")
    public String addarea(@RequestParam String name) {
        areaService.save(name);
        return "Success";
    }

    @RequestMapping(value = "/areamod")
    public String modarea(@RequestParam int id,
                          @RequestParam String name) {
        areaService.save(id, name);
        return "Success";
    }

    @RequestMapping(value = "/areadel")
    public String deletearea(@RequestParam int id) {
        areaService.delete(id);
        return "Success";
    }

    @RequestMapping(value = "/areaall")
    public List<area> listarea() {
        return areaService.findAll();
    }
}
